package com.cn.icss.vo.common;

import lombok.Data;
import lombok.ToString;

/**
 * @中软华腾软件系统有限公司,未经授权不得擅自传播
 * @类描述: 统一的返回结果的封装
 * @类名称:ResponseResult
 * @作者: Administrator
 * @编辑时间: 2020/04/08 14:05
 * @版本: 1.0
 */
@Data
@ToString
public class ResponseResult {
    // 状态码
    public  Integer code;
    // 回应消息
    private String msg;
    // 状态信息
    private boolean status;
    // 响应的数据
    private Object data;

    private ResponseResult(){

    }

    public ResponseResult(Integer code, String msg, boolean status, Object data) {
        this.code = code;
        this.msg = msg;
        this.status = status;
        this.data = data;
    }

    private ResponseResult(ResponseCode code, String msg, ResponseStatus responseStatus, Object data){
        this.code = code.getStatusCode();
        this.msg = msg;
        this.status = responseStatus.getStatus();
        this.data = data;
    }

    private ResponseResult(Object data){
        this.code = ResponseCode.OK.getStatusCode();
        this.msg = "OK";
        this.status = ResponseStatus.SUCCESS.getStatus();
        this.data = data;
    }

    public static ResponseResult build(ResponseCode code,String msg, ResponseStatus status, Object data){
        return new ResponseResult(code, msg, status, data);
    }

    public static ResponseResult build(ResponseCode code,String msg,ResponseStatus status){
        return new ResponseResult(code,msg,status,null);
    }

    public static ResponseResult ok(){
        return  new ResponseResult(null);
    }

    public static ResponseResult ok(Object data){
        return new ResponseResult(data);
    }


}
